define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'pro/normaluser/index',
                    // add_url: 'pro/normaluser/add',
                    // edit_url: 'pro/normaluser/edit',
                    // del_url: 'pro/normaluser/del',
                    // multi_url: 'pro/normaluser/multi',
                    table: 'gzns_user_info',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                      // {checkbox: true},
                        {field: 'id', title: __('Id')},
                      {field: 'avatar', title: __('Avatar'), formatter: Table.api.formatter.image,operate: false},
                      {field: 'nick_name', title: __('Nick_name'),
                        formatter: function (value, row, index) {
                          if (!value) {
                            return '游客'
                          }
                          return value
                        }},
                        {field: 'sex', title: __('Sex'), searchList: {"0":__('Sex 0'),"1":__('Sex 1')}, formatter: Table.api.formatter.status},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
